﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LabMonitorRemote
{
    static class LMRStaticUtilities
    {
        public static bool ValidIPAddress(string ip)
        {
            string[] octets = ip.Split(".".ToCharArray());
            if (octets.Length < 4)
            {
                // not a valid IPv4 string in X.X.X.X format
                return false;
            }
            else
                foreach (string octet in octets)
                {
                    byte checkPart = 0;
                    if (!byte.TryParse(octet, out checkPart))
                    {
                        // not a valid IPv4 string in X.X.X.X format
                        return false;
                    }
                }
            // string is a valid IPv4 string in X.X.X.X format
            return true;
        }
    }
}
